package fido.torrentsite;

import fido.DummyTorrent;
import fido.Torrent;
import fido.exceptions.IncorrectCookieException;
import fido.exceptions.NotConfiguredException;
import org.mymediadb.api.mmdb.model.Movie;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Anders
 * Date: 10.07.11
 * Time: 21:39
 */
public class DummyTorrentSite implements TorrentSite {
    private List<Movie> movies;
    private boolean configured;

    public DummyTorrentSite() {
        movies = new ArrayList<Movie>();
        configured = false;
    }

    @Override
    public String getTorrentSiteAlias() {
        return "DummyTorrentSite";
    }

    /**
     * Just a movie adder, so that the TorrentSite can return a Torrent if the movie is added.
     * @param movie the movie to add.
     */
    public void addMovie(Movie movie) {
        movies.add(movie);
    }

    @Override
    public Torrent search(Movie movie) throws NotConfiguredException, IncorrectCookieException {
        if (movies.contains(movie)) {
            return new DummyTorrent();
        }
        return null;
    }

    @Override
    public void configureWithGUI() throws NotConfiguredException {
         configured = true;
    }

    @Override
    public void configureWithTUI() {
         configured = true;
    }

    @Override
    public boolean isConfigured() {
        return configured;
    }

    public void setConfigured(boolean flag) {
        configured = flag;
    }
}
